var t = getApp(), a = require("../../utils/util.js"), e = require("../../nitro.js"), n = (require("../../configs.js"), 
{
    theme: {
        title: "小主题系列",
        subtitle: "适合年龄：23个月以上，提供服装/可自带衣服",
        slogan: "100%保证客片效果/丰富主题选择"
    },
    look: {
        title: "LOOK 系列",
        subtitle: "适合年龄：23个月以上 提供服装/可自带衣服/含全家福",
        slogan: "时尚大片/创意场景/独一无二"
    },
    face: {
        title: "FACE 系列",
        subtitle: "适合年龄：23个月以上 提供服装/可自带衣服/含全家福",
        slogan: "纯净清爽/耐看/经典大头照"
    },
    life: {
        title: "生活写真系列",
        subtitle: "适合年龄：0-12个月宝宝 提供服装/可自带衣服/含全家福",
        slogan: "记录生活/自然光/日系文艺风格"
    },
    baby: {
        title: "BABY 系列",
        subtitle: "适合年龄：10个月-23个月 提供服装/可自带衣服/含全家福",
        slogan: "可爱呆萌/温馨满满"
    }
}), o = function(t, e) {
    return t.forEach(function(t) {
        t.packages = [], t.gallery = [], e.forEach(function(e) {
            e.category && e.category.id == t.id && (t.packages.push(e), t.gallery = a.shuffle(t.gallery.concat(e.gallery)).slice(0, 15));
        }), t.hasSubItems = t.title.indexOf("小主题") > -1, t.title.includes("小主题") ? (t.mp_info = n.theme, 
        t.is_themes = !0) : t.title.toLowerCase().includes("look") ? t.mp_info = n.look : t.title.toLowerCase().includes("face") ? t.mp_info = n.face : t.title.toLowerCase().includes("baby") && (t.mp_info = n.baby);
    }), console.info("processPackages", t), t.filter(function(t) {
        return t.publish;
    });
};

Page({
    data: {
        isIpx: t.globalData.isIpx,
        storeId: "",
        disabledScroll: !1,
        categories: [],
        gallery: {},
        defaultBanners: [ {
            url: "https://nitro-prod.oss-cn-hangzhou.aliyuncs.com/public/mp-banner-3.jpg",
            link: ""
        }, {
            url: "https://nitro-prod.oss-cn-hangzhou.aliyuncs.com/public/mp-banner-4.jpg",
            link: ""
        } ],
        artworkTabs: [],
        indicatorDots: !1,
        autoplay: !1,
        interval: 5e3,
        duration: 1e3
    },
    onLoad: function(e) {
        var n = e.store_id || "a13e5bca9835edf92bb4aa50", o = e.type;
        t.globalData.ts = +new Date(), wx.showLoading({}), this.setData({
            storeId: n,
            brandType: o,
            artworkTabs: (a.config("artworkTabs_" + o) || []).map(function(t) {
                return t.active = !1, t;
            }),
            campaign: t.globalData.campaign || !1,
            showCampaignSplash: !!t.globalData.campaign
        }), t.globalData.campaign && t.campaignEventLog("view_splash"), this.initData(n);
    },
    onReady: function() {
        wx.setNavigationBarColor({
            frontColor: "#000000",
            backgroundColor: "#ffffff",
            animation: {
                duration: 400,
                timingFunc: "easeIn"
            }
        });
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {
        return {
            title: "尼可儿童摄影",
            path: "/pages/stores/stores"
        };
    },
    tapCampaignSplash: function() {
        t.campaignEventLog("click_splash"), console.log("tapCampaignSplash"), this.setData({
            showCampaignSplash: !1
        });
    },
    initData: function(n) {
        var i = this, r = n || e.getStore()._id;
        console.info("initData start", +new Date() - t.globalData.ts), e.fetchMPConfigs().then(function(t) {
            var a = t.banners || [];
            i.setData({
                banners: a
            });
        }), e.fetchProducts(r).then(function(n) {
            var r = o(n.categories, n.items), c = r.find(function(t) {
                return t.is_themes;
            }).packages.map(function(t) {
                return {
                    title: t.title,
                    id: t._id,
                    cover: t.gallery.length && t.gallery[0].url.raw,
                    category_id: t.category._id
                };
            }), s = a.chunkArray(c.filter(function(t) {
                return t.cover;
            }), 6);
            console.info("themeGroups>>>", s), i.setData({
                store: e.getStore(),
                packageLoaded: !0,
                categories: r,
                themeGroups: s
            }), wx.setNavigationBarTitle({
                title: "" + i.data.store.name
            }), wx.hideLoading(), console.info("hideLoading", +new Date() - t.globalData.ts);
        });
    },
    onPreviewSlides: function(t) {
        t.currentTarget.dataset.url;
        var a = t.currentTarget.dataset.category;
        t.currentTarget.dataset.package;
        wx.navigateTo({
            url: "/pages/product-detail/product-detail?category_id=" + a,
            success: function(t) {},
            fail: function(t) {},
            complete: function(t) {}
        });
    },
    loadThemePhotos: function(t) {
        var a = t.currentTarget.dataset.id;
        console.log("e.currentTarget.dataset", t.currentTarget.dataset), wx.navigateTo({
            url: "/pages/themes/themes?category_id=" + a,
            success: function(t) {},
            fail: function(t) {},
            complete: function(t) {}
        });
    },
    loadMorePhotos: function(t) {
        var a = t.currentTarget.dataset.category;
        t.currentTarget.dataset.package;
        wx.navigateTo({
            url: "/pages/product-detail/product-detail?category_id=" + a,
            success: function(t) {},
            fail: function(t) {},
            complete: function(t) {}
        });
    },
    gotoProductDetail: function(t) {
        var a = t.currentTarget.dataset.categoryid;
        wx.navigateTo({
            url: "/pages/product-detail/product-detail?category_id=" + a + "&type=" + this.data.brandType,
            success: function(t) {},
            fail: function(t) {},
            complete: function(t) {}
        });
    },
    onSwitchTab: function(t) {
        var a = t.currentTarget.dataset.categoryid;
        wx.navigateTo({
            url: "/pages/product-detail/product-detail?category_id=" + a + "&type=" + this.data.brandType,
            success: function(t) {},
            fail: function(t) {},
            complete: function(t) {}
        });
    },
    gotoBannerLink: function(t) {
        var a = t.currentTarget.dataset.link;
        console.info("open link", a), a && (a.includes("https://mp.weixin.qq.com") || a.includes("nicokids.cn")) && wx.navigateTo({
            url: "/pages/webview/webview?link=" + a
        });
    }
});